package com.king.core.nio;


import java.io.Closeable;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

/**
 * 描述:
 *
 * @author : sujinchen
 * @date : 2020/11/2
 */
public class Demo implements Closeable {

    public static void main(String[] args) {
        //关键点：使用try()-catch的方式来实现自动释放
        try(Demo demo = new Demo()) {
            demo.close();
            System.out.println("demo start");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void close() throws IOException {
        System.out.println("IO释放啦");
    }
}
